package com.bwie.es.controller;

import com.bwie.common.domain.Article;
import com.bwie.common.domain.response.ArticleDTO;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.es.service.EsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/es")
public class EsController {

    @Autowired
    private EsService esService;

    @PostMapping("/findEsList")
    public Result findEsList(@RequestBody ArticleDTO articleDTO){
        PageResult<Article> esList = esService.findEsList(articleDTO);
        return Result.success(esList);
    }

    @PostMapping("/batch")
    public Result batch(@RequestBody List<Article> articles){
        esService.batch(articles);
        return Result.success();
    }

}
